﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BathhouseService.Models.SqlModels;


namespace BathhouseService.CURD.ViewModels.ShufflingFigureVMs
{
    public partial class ShufflingFigureListVM : BasePagedListVM<ShufflingFigure_View, ShufflingFigureSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.Create, "新建","CURD", dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.Edit, "修改","CURD", dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.Delete, "删除", "CURD",dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.Details, "详细","CURD", dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.BatchEdit, "批量修改","CURD", dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.BatchDelete, "批量删除","CURD", dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.Import, "导入","CURD", dialogWidth: 800),
                this.MakeStandardAction("ShufflingFigure", GridActionStandardTypesEnum.ExportExcel, "导出","CURD"),
            };
        }

        protected override IEnumerable<IGridColumn<ShufflingFigure_View>> InitGridHeader()
        {
            return new List<GridColumn<ShufflingFigure_View>>{
                this.MakeGridHeader(x => x.PhotoId).SetFormat(PhotoIdFormat),
                this.MakeGridHeaderAction(width: 200)
            };
        }
        private List<ColumnFormatInfo> PhotoIdFormat(ShufflingFigure_View entity, object val)
        {
            return new List<ColumnFormatInfo>
            {
                ColumnFormatInfo.MakeDownloadButton(ButtonTypesEnum.Button,entity.PhotoId),
                ColumnFormatInfo.MakeViewButton(ButtonTypesEnum.Button,entity.PhotoId,640,480),
            };
        }


        public override IOrderedQueryable<ShufflingFigure_View> GetSearchQuery()
        {
            var query = DC.Set<ShufflingFigure>()
                .Select(x => new ShufflingFigure_View
                {
				    ID = x.ID,
                    PhotoId = x.PhotoId,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class ShufflingFigure_View : ShufflingFigure{

    }
}
